/**
 * 
 */
package com.ap.core.business.routing.service.impl;

import org.springframework.transaction.annotation.Transactional;

import com.ap.core.business.routing.service.api.EndPointRoutingService;
import com.ap.core.common.types.ServiceMessageType;
import com.ap.core.cxf.jaxb.managerefund.RoutingInfoType;
import com.ap.core.dao.EndPointRoutingDao;
import com.ap.core.domain.EndPointRouting;

/**
 * The Implementation Class for AP Transaction Generation Service.
 *
 * @author Rohit.Dixit
 */
public class EndPointRoutingServiceImpl implements 	EndPointRoutingService<RoutingInfoType> {
	

	
	private EndPointRoutingDao  endPointRoutingDao;	
	


	@Override
	@Transactional(readOnly=true)
	public RoutingInfoType getEndPointRoutingInfo(String TargetId, String msgType) {
		
		ServiceMessageType serviceMessageType = ServiceMessageType.getMessageType(msgType);
		
		EndPointRouting endPointRouting = endPointRoutingDao.findByTargetIdAndTypeAndOperationName(TargetId, serviceMessageType.getDestinationType() ,serviceMessageType.getOperationName().name());
		
		RoutingInfoType routingInfo = new RoutingInfoType();
		routingInfo.setServiceVersion(endPointRouting.getDestinationService());
		routingInfo.setTargetURI(endPointRouting.getDestinationUri());
		return routingInfo;
	}



	public void setEndPointRoutingDao(EndPointRoutingDao endPointRoutingDao) {
		this.endPointRoutingDao = endPointRoutingDao;
	}


}
